
root=Node()
axes = Node(root)
axes.Load("axes.osg")
axes.SetScale(10,10,10)
cow =Node(root)
cow.Load("cow.osg")

title=Text(root,"ciao")
title.SetAlign(CENTER_CENTER)
title.SetPosition(0,430)

viewer.SetRoot(root)    
    
#---------------------------------    
def cp():
    print "cp = CameraPose", cm.GetPose().Repr()
    
#---------------------------------    

# 1) --- espressione invece di Valore 0
# 2) --- 

def slide1():
    
    cp  = cm.GetPose()
    cp0 = CameraPose(4.5, 4.5, 4.5, 56, 90, 1, 0, 0)
    cp1 = CameraPose(0, 0, 4, 50, 95, 1, 0, 0)
    cp2 = CameraPose(-0.4, -30, 0.5, 18, 90, 1, 0, 0)
    
    title.SetText("this is slide 1")
    am.clear()
    a1 = Anim( [],  1,  title.SetPosition, Vec(0,430,0), Vec(800,430,0)  )
    b =  Anim( [],  1,  cm.SetPose, cp, cp2  )
    b  = Call( [a1],    title.SetText, "this is slide 1" )
    b  = Call( [a1],    cow.SetPosition, Vec(0,0,0) )
    b  = Call( [a1],    cow.SetRotation, Quat(0,1,0,0) )
    b  = Call( [a1],    cow.SetScale,    Vec(1,1,1) )
    a2 = Anim( [a1], 1, title.SetPosition, Vec(-800,430,0), Vec(0,430,0)  )
    a2 = Anim( [a1], 1, title.SetPosition, Vec(-800,430,0), Vec(0,430,0)  )

    a3 = Anim( [a2], 1, cow.SetRotation, Quat(), Quat(-90,0,0,1)  )
    a4 = Anim( [a2], 1, cow.SetPosition, Vec(0,0,0),  Vec(0,-30,0) )
    a5 = Wait( [a3,a4], 1 )
    b  = Anim( [a5], 1, cow.SetRotation, Quat(-90,0,0,1), Quat() )
    b  = Anim( [a5], 1, cow.SetPosition, Vec(0,-30,0), Vec(0,0,0) )
    am.play()
    
def slide2():
    cp  = cm.GetPose()
    cp0 = CameraPose(4.5, 4.5, 4.5, 56, 90, 1, 0, 0)

    title.SetText("this is slide 2")
    am.clear()
    a = Anim( [],  1, title.SetPosition, Vec(0,430,0), Vec(800,430,0)  )
    b = Anim( [],  1,  cm.SetPose, cp, cp0  )
    b = Call( [a],    title.SetText, "this is slide 2" )
    b = Call( [a],    cow.SetPosition, Vec(0,0,0) )
    b = Call( [a],    cow.SetRotation, Quat(0,0,0,0) )
    b = Call( [a],    cow.SetScale,    Vec(0,0,0) )
    a = Anim( [a], 1, title.SetPosition, Vec(-800,430,0), Vec(0,430,0)  )

    b = Anim( [a], 3, cow.SetRotation, Quat(), Quat(-90,0,0,1)  )
    a = Anim( [a], 1, cow.SetPosition, Vec(0,0,0),  Vec(0,-10,0) )
    a = Wait( [a], 1 )
    b = Anim( [a], 3, cow.SetRotation, Quat(-90,0,0,1), Quat() )
    b = Anim( [a], 1, cow.SetPosition, Vec(0,-10,0), Vec(0,0,0) )
    am.play()

#---------------------------------    
slides = [
  ("slide1",slide1),
  ("slide2",slide2),
]


